//
//  NextViewController.m
//  iOSDemo
//
//  Created by login on 15-6-29.
//  Copyright (c) 2015年 login. All rights reserved.
//

#import "NextViewController.h"
#import "Header.h"
#import "WhereGoViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "PersonalCenterViewController.h"
@interface NextViewController ()
@end

@implementation NextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (UIViewController *)turnToNextViewController:(NSString *)selectView andDic:(NSDictionary *)dic
{

    id nextView = [[NSClassFromString(dic[selectView])alloc]init];
    
    if ([nextView isKindOfClass:[UIViewController class]]) {
        
        NSLog(@"成功加载视图");
//        当访问导航栏的时候更改返回UITabBarController
        if ([nextView isKindOfClass:[WhereGoViewController class]]) {
            return [self changeRootViewController];
        }
        
        return nextView;
    }
    return nil;
}

- (UIViewController *)changeRootViewController
{
    UITabBarController *tb = [[UITabBarController alloc]init];
    
    WhereGoViewController *where = [[WhereGoViewController alloc]init];
    where.tabBarItem.title = @"首页";
    
    SecondViewController *second = [[SecondViewController alloc]init];
    second.view.backgroundColor = [UIColor whiteColor];
    second.tabBarItem.title = @"第二页";
    
    ThirdViewController *third = [[ThirdViewController alloc]init];
    third.view.backgroundColor = [UIColor brownColor];
    third.tabBarItem.title = @"第三页";
    
    PersonalCenterViewController *fourth = [[PersonalCenterViewController alloc]init];
    fourth.tabBarItem.title = @"第四页";
    

    tb.viewControllers = @[where,second,third,fourth];
    
    tb.hidesBottomBarWhenPushed = YES;
    
    return tb;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
